package Book;

import java.util.Objects;

public class Book {
    private String bookname;
    private int price;
    private String author;
    private String type;
    private boolean islended;//表示借出状态

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return price == book.price && islended == book.islended && Objects.equals(bookname, book.bookname) && Objects.equals(author, book.author) && Objects.equals(type, book.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bookname, price, author, type, islended);
    }

    public Book(String bookname, String author , int price, String type) {
        this.bookname = bookname;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isIslended() {
        return islended;
    }

    public void setIslended(boolean islended) {
        this.islended = islended;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookname='" + bookname + '\'' +
                ", price=" + price +
                ", author='" + author + '\'' +
                ", type='" + type + '\'' +
                (islended == true ? "已借出" : "未借出") +
                '}';
    }
}
